﻿@using Aspire.Dashboard.Resources
@typeparam T

<div class="summary-details-container">
    @if (!ViewportInformation.IsDesktop)
    {
        @if (_internalShowDetails)
        {
            <DetailView
                DetailsTitle="@DetailsTitle"
                DetailsTitleTemplate="@(SelectedValue is not null ? DetailsTitleTemplate?.Invoke(SelectedValue) : null)"
                HandleDismissAsync="@HandleDismissAsync"
                HandleToggleOrientation="@HandleToggleOrientation"
                Details="@(SelectedValue is not null ? Details?.Invoke(SelectedValue) : null)"
                Orientation="@Orientation" />
        }
        else
        {
            <div class="summary-container">
                @Summary
            </div>
        }
    }
    else
    {
        <FluentSplitter Orientation="@Orientation" Collapsed="@(!_internalShowDetails)"
                        OnResized="HandleSplitterResize"
                        Panel1Size="@EffectivePanel1Size" Panel2Size="@EffectivePanel2Size"
                        Panel1MinSize="@PanelMinimumSize" Panel2MinSize="@PanelMinimumSize"
                        BarSize="5"
                        @ref="_splitterRef">
            <Panel1>
                <div class="summary-container">
                    @Summary
                </div>
            </Panel1>
            <Panel2>
                @if (_internalShowDetails)
                {
                    <DetailView
                        DetailsTitle="@DetailsTitle"
                        DetailsTitleTemplate="@(SelectedValue is not null ? DetailsTitleTemplate?.Invoke(SelectedValue) : null)"
                        HandleDismissAsync="@HandleDismissAsync"
                        HandleToggleOrientation="@HandleToggleOrientation"
                        Details="@(SelectedValue is not null ? Details?.Invoke(SelectedValue) : null)"
                        Orientation="@Orientation"/>
                }
            </Panel2>
        </FluentSplitter>
    }
</div>
